home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 119
/
(Vol 119) Nov 09 2010.iso
/
Games
/
orbitrax.swf
/
scripts
/
DefineSprite_683
/
frame_1
/
PlaceObject2_682_246
/
CLIPACTIONRECORD onClipEvent(enterFrame).as
next >
Wrap
Text File
|
2010-11-09
|
6KB
|
229 lines
onClipEvent(enterFrame){
if(main.keyActive)
{
main.timerGame = getTimer() - main.offSet;
minut = Math.round(main.timerGame / 1000 / 60);
second = Math.round(main.timerGame / 1000 % 60);
centiSecond = Math.round(main.timerGame % 1000 / 10);
main.minutTxt = minut >= 10 ? minut : "0" + minut;
main.secondTxt = second >= 10 ? second : "0" + second;
main.centiSecondTxt = centiSecond >= 10 ? centiSecond : "0" + centiSecond;
keyLeft = Key.isDown(37);
keyRight = Key.isDown(39);
keyup = Key.isDown(38);
keydown = Key.isDown(40);
}
else
{
keyLeft = keyRight = keyup = keydown = false;
}
gHit = gObj;
var i = 0;
while(i < gameMain.hitObjList.gArray.length)
{
hitG = gameMain.hitObjList.gArray[i].hitTest(_X * _parent._xscale / 100 + _parent._x,_Y * _parent._yscale / 100 + _parent._y,true);
if(hitG)
{
gHit = gameMain.hitObjList.gArray[i];
break;
}
i++;
}
if(gameMain.twins.oil.hitZone.hitTest(gameMain.allCar))
{
gameMain.twins.oil.gotoAndPlay("hit");
gHit = gameMain.twins.oil;
}
if(keyup)
{
dir = 1;
tspeed += dir * (trust * gHit.gf);
}
if(keydown)
{
dir = -1;
tspeed += dir * (btrust * gHit.gf);
}
tspeed = Math.min(tspeed,main.ultimateSpeed);
hVolume = tspeed * 100 / 12;
gameMain.lowSpeed.s.setVolume(100 - hVolume);
gameMain.highSpeed.s.setVolume(Math.min(hVolume,80));
tspeed *= decay;
angDeg = angle * gameMain.radVal;
idealvx = tspeed * Math.cos(angDeg);
idealvy = tspeed * Math.sin(angDeg);
vx += (idealvx - vx) * tfriction;
vy += (idealvy - vy) * tfriction;
x += vx;
y += vy;
if(keyLeft || keyRight)
{
steer += (keyRight - keyLeft) * steerInc;
}
else
{
steer += ((steer < 0) - (steer > 0)) * steerDec;
}
if(steer < - steerMax)
{
steer = - steerMax;
}
else if(steer > steerMax)
{
steer = steerMax;
}
speed = Math.sqrt(vx * vx + vy * vy);
angle += steer * speed * gHit.steerSmooth;
gameMain.allCar.wtl._rotation = gameMain.allCar.wtr._rotation = steer * 3 * dir;
gameMain.carShadow._rotation = gameMain.allCar._rotation = angle + 90;
if(x < 150)
{
_X = x = 160;
vx = 0;
vy = 0;
}
else if(x > 1850)
{
_X = x = 1840;
vx = 0;
vy = 0;
}
else
{
_X = x;
}
if(y < 110)
{
_Y = y = 120;
vx = 0;
vy = 0;
}
else if(y > 1400)
{
_Y = y = 1390;
vx = 0;
vy = 0;
}
else
{
_Y = y;
}
var i = 1;
while(i <= gameMain.hitZoneQty)
{
if(hitZone.hitTest(eval("gameMain.hitZone" + i)))
{
gameMain.hitObjList = eval("gameMain.zoneArray" + i);
}
i++;
}
upHit = false;
i = 0;
while(i < gameMain.upArray.length)
{
if(gameMain.upArray[i].hitTest(this.hitZone) && gameMain.swapObj.getDepth() > gameMain.elementMap.getDepth())
{
upHit = true;
if(gameMain.allCar.car._xscale < 70)
{
gameMain.allCar.car._xscale = gameMain.allCar.car._yscale += 5;
}
}
i++;
}
if(!upHit && gameMain.allCar.car._xscale > 65)
{
gameMain.allCar.car._xscale = gameMain.allCar.car._yscale -= 5;
}
i = 0;
while(i < gameMain.hitObjList.hitArray.length)
{
if(gameMain.hitObjList.hitArray[i].hitTest(this.hitZone))
{
gameMain.hitObjList.hitArray[i].hitAction();
}
i++;
}
bump = tspeed <= 0 ? "bumpBack" : "bumpFront";
i = 0;
while(i < gameMain.hitObjList.obsArray.length)
{
if(gameMain.checkObs(this,gameMain.hitObjList.obsArray[i]))
{
if(gameMain.carAnim != "jumpFront" && gameMain.carAnim != "jumpSide")
{
gameMain.allCar.car.gotoAndStop(bump);
gameMain.bumpSnd.gotoAndPlay("bump");
}
}
i++;
}
var i = 0;
var i = 0;
while(i <= gameMain.hitObjList.borderArray.length)
{
if(gameMain.checkBorder(this,gameMain.hitObjList.borderArray[i]))
{
if(gameMain.hitObjList.borderArray[i].dommage == undefined)
{
if(gameMain.carAnim != "jumpFront" && gameMain.carAnim != "jumpSide")
{
gameMain.allCar.car.gotoAndStop(bump);
gameMain.bumpSnd.gotoAndPlay("bump");
}
}
}
i++;
}
if(Math.abs(Math.round(steer)) > skidAngle && speed > skidSpeed || hitG)
{
gameMain.traceLine(_X,_Y,gHit,moveTo);
if(keyRight || keyLeft)
{
skid = true;
skidSide = !keyRight ? "skid2" : "skid1";
}
if(gameMain.carAnim != "jumpFront" && gameMain.carAnim != "jumpSide")
{
gameMain.skidSound.gotoAndStop("snd");
gameMain.allCar.car.gotoAndStop(skidSide);
}
moveTo = false;
}
else
{
moveTo = true;
if(skid)
{
if(gameMain.carAnim != "jumpFront" && gameMain.carAnim != "jumpSide")
{
skid = false;
gameMain.skidSound.gotoAndStop("mute");
gameMain.allCar.car.gotoAndStop(skidSide + "b");
}
}
gameMain.lineL.clear();
gameMain.lineR.clear();
}
gameMain.twins._x = gameMain.elementMap._x = gameMain.map._x = Math.round(- _X + gameMain.allCar._x);
gameMain.twins._y = gameMain.elementMap._y = gameMain.map._y = Math.round(- _Y + gameMain.allCar._y);
if(gameMain.twins.energyBoost.hitZone.hitTest(gameMain.allCar))
{
gameMain.twins.energyBoost.gotoAndPlay("hit");
}
if(gameMain.twins.speedBoost.hitZone.hitTest(gameMain.allCar))
{
gameMain.twins.speedBoost.gotoAndPlay("hit");
}
var i = 0;
while(i < gameMain.mapArray.length)
{
gameMain.mapArray[i]._visible = gameMain.mapArray[i].hitTest(gameMain.frame);
i++;
}
for(var i in gameMain.twins)
{
gameMain.twins[i]._visible = gameMain.twins[i].hitTest(gameMain.frame) && gameMain.twins[i].actif != false;
}
}